/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.entity.*;
import org.springblade.modules.admin.service.*;
import org.springblade.modules.admin.vo.plan.PerformanceVoV2;
import org.springblade.modules.admin.vo.user.UserSalarySheetVo;
import org.springblade.modules.system.entity.Dict;
import org.springblade.modules.system.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.admin.vo.UserSalaryVO;
import org.springblade.modules.admin.wrapper.UserSalaryWrapper;
import org.springblade.core.boot.ctrl.BladeController;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户工资表 控制器
 *
 * @author ysq
 * @since 2025-05-22
 */
@RestController
@AllArgsConstructor
@RequestMapping("admin/usersalary")
@Api(value = "用户工资表", tags = "用户工资表接口")
public class UserSalaryController extends BladeController {

	private final IUserSalaryService userSalaryService;
	private final IDictService dictService;
	private final IUserElevatorSkillService userElevatorSkillService;
	private final IUserSalaryMonthDetailService userSalaryMonthDetailService;
	private final IUserSalaryRulesService userSalaryRulesService;
	private final IUserSalaryRulesHistoryService userSalaryRulesHistoryService;

	@GetMapping("/detail")
	@ApiOperation(value = "绩效详情", notes = "传入userSalary")
	public R detail(Long salaryMonthId) {
		List<UserSalaryMonthDetail> userSalaryServiceAll = userSalaryMonthDetailService.list(Wrappers.<UserSalaryMonthDetail>lambdaQuery().eq(UserSalaryMonthDetail::getSalaryMonthId, salaryMonthId));
		JSONObject jsonObject = new JSONObject(2);
		jsonObject.put("one_user", userSalaryServiceAll);
		jsonObject.put("all_user", getAllUserSalary(userSalaryServiceAll));
		return R.data(jsonObject);
	}

	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入userSalary")
	public R save(@RequestBody List<UserSalary> list) {
		userSalaryService.remove(Wrappers.<UserSalary>lambdaQuery().isNotNull(UserSalary::getId));
		return R.data(userSalaryService.saveOrUpdateBatch(list));
	}

	@PostMapping("/list")
	@ApiOperation(value = "列表", notes = "传入userSalary")
	public R<List<UserSalary>> list(@RequestBody UserSalary userSalary) {
		List<UserSalary> list = userSalaryService.list(userSalary);
		return R.data(list);
	}

	@GetMapping("update/userElevatorSkill")
	@ApiOperation(value = "更新用户技能等级", notes = "更新用户技能等级")
	public R<Boolean> update(Long userId, Long skillId) {
		Dict dict = dictService.getById(skillId);
		UserElevatorSkill userElevatorSkill = userElevatorSkillService.getOne(Wrappers.<UserElevatorSkill>lambdaQuery().eq(UserElevatorSkill::getUserId, userId));
		if (userElevatorSkill == null) {
			userElevatorSkill = new UserElevatorSkill();
		}
		userElevatorSkill.setUserId(userId);
		userElevatorSkill.setSkillId(dict.getId());
		userElevatorSkill.setSkillKey(Convert.toInt(dict.getDictKey()));
		userElevatorSkill.setSkillName(dict.getDictValue());
		userElevatorSkillService.saveOrUpdate(userElevatorSkill);
		return R.data(true);
	}


	@PostMapping("get/all")
	@ApiOperation(value = "获取用户的工资", notes = "获取用户的工资")
	public R<JSONObject> getAll(@RequestBody UserSalaryRules userSalaryRules) {
		JSONObject jsonObject = new JSONObject(2);
		List<UserSalaryMonthDetail> userSalaryServiceAll = userSalaryService.getAll(userSalaryRules);
		jsonObject.put("one_user", userSalaryServiceAll);
		jsonObject.put("all_user", getAllUserSalary(userSalaryServiceAll));
		return R.data(jsonObject);
	}


	@PostMapping("down/excel")
	@ApiOperation(value = "下载Excel", notes = "下载Excel")
	public void downExcel(HttpServletResponse response, @RequestBody UserSalaryRules userSalaryRules) throws IOException {
		List<UserSalaryMonthDetail> userSalaryServiceAll;
		List<UserSalaryRules> searchUserSalaryRules = new ArrayList<>(34);
		if (userSalaryRules.getSalaryMonthId() != null) {
			userSalaryServiceAll = userSalaryMonthDetailService.list(Wrappers.<UserSalaryMonthDetail>lambdaQuery().eq(UserSalaryMonthDetail::getSalaryMonthId, userSalaryRules.getSalaryMonthId()));
			List<UserSalaryRulesHistory> rulesHistoryList = userSalaryRulesHistoryService.list(Wrappers.<UserSalaryRulesHistory>lambdaQuery().eq(UserSalaryRulesHistory::getSalaryMonthId, userSalaryRules.getSalaryMonthId()).eq(UserSalaryRulesHistory::getStatus, 1).orderByAsc(UserSalaryRulesHistory::getSort));
			for (UserSalaryRulesHistory userSalaryRulesHistory : rulesHistoryList) {
				UserSalaryRules userSalaryRules1 = new UserSalaryRules();
				BeanUtil.copyProperties(userSalaryRulesHistory, userSalaryRules1);
				searchUserSalaryRules.add(userSalaryRules1);
			}
		} else {
			searchUserSalaryRules = userSalaryRulesService.list(Wrappers.<UserSalaryRules>lambdaQuery().eq(UserSalaryRules::getTemplateId, userSalaryRules.getTemplateId()).eq(UserSalaryRules::getStatus, 1).orderByAsc(UserSalaryRules::getSort));
			userSalaryServiceAll = userSalaryService.getAll(userSalaryRules);
		}
		ExcelWriter excelWriter = null;
		ServletOutputStream outputStream = response.getOutputStream();
		try {
			List<List<String>> rows = new ArrayList<>();
			List<String> title = new ArrayList<>(searchUserSalaryRules.size());
			for (UserSalaryRules userSalaryRules1 : searchUserSalaryRules) {
				title.add(userSalaryRules1.getName());
			}
			rows.add(title);
			for (UserSalaryMonthDetail userSalaryMonthDetail : userSalaryServiceAll) {
				List<String> row = excelSort(searchUserSalaryRules, userSalaryMonthDetail);
				rows.add(row);
			}
			rows.add(getExcelTitle(searchUserSalaryRules));
			rows.add(excelSortAll(searchUserSalaryRules, getAllUserSalary(userSalaryServiceAll)));
			String fileName = DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".xlsx";
			setResponseHeader(response, fileName);
			excelWriter = ExcelUtil.getBigWriter(rows.size());
			excelWriter.write(rows, true);
			excelWriter.flush(outputStream, true);
		} catch (
			Exception e) {
			e.printStackTrace();
		} finally {
			if (excelWriter != null) {
				excelWriter.close();
			}
			outputStream.close();
		}
	}

	/**
	 * 功能描述: 发送响应流方法
	 */
	private void setResponseHeader(HttpServletResponse response, String fileName) {
		try {
			try {
				fileName = new String(fileName.getBytes(), "ISO8859-1");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
			response.setContentType("application/octet-stream;charset=ISO8859-1");
			response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
			response.addHeader("Pargam", "no-cache");
			response.addHeader("Cache-Control", "no-cache");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}


	/**
	 * 人员工资统计
	 *
	 * @param userSalaryServiceAll 人员工资
	 * @return 数据集
	 */
	private UserSalarySheetVo getAllUserSalary(List<UserSalaryMonthDetail> userSalaryServiceAll) {
		UserSalarySheetVo userSalarySheetVo = new UserSalarySheetVo();
		userSalarySheetVo.setUserCounts(userSalaryServiceAll.size());

		Integer expertCounts = 0;

		BigDecimal myElevatorCounts = Convert.toBigDecimal(0);

		BigDecimal myElevatorNsCounts = Convert.toBigDecimal(0);

		BigDecimal myElevatorVillaCounts = Convert.toBigDecimal(0);

		Integer byNullifyPlanCounts = 0;

		Integer wxNullifyPlanCounts = 0;

		Integer expertHelpCounts = 0;

		Integer wxExpertHelpCounts = 0;

		Integer byExpertHelpCounts = 0;

		Integer expertHelpOtherCounts = 0;

		BigDecimal userSalary = Convert.toBigDecimal(0);

		BigDecimal roleSalary = Convert.toBigDecimal(0);

		BigDecimal byPerformance = Convert.toBigDecimal(0);

		BigDecimal wxPerformance = Convert.toBigDecimal(0);

		BigDecimal nsPerformance = Convert.toBigDecimal(0);

		BigDecimal failureRatePunish = Convert.toBigDecimal(0);

		BigDecimal byNoPassPunish = Convert.toBigDecimal(0);

		BigDecimal wxNoPassPunish = Convert.toBigDecimal(0);

		BigDecimal byLiabilityPunish = Convert.toBigDecimal(0);

		BigDecimal wxLiabilityPunish = Convert.toBigDecimal(0);

		BigDecimal expertPunish = Convert.toBigDecimal(0);

		BigDecimal expertBonus = Convert.toBigDecimal(0);

		BigDecimal minSalary = Convert.toBigDecimal(0);

		BigDecimal performanceSalary = Convert.toBigDecimal(0);

		BigDecimal disAllSalary = Convert.toBigDecimal(0);

		BigDecimal managerBonus = Convert.toBigDecimal(0);

		BigDecimal managerPunish = Convert.toBigDecimal(0);

		BigDecimal enAllSalary = Convert.toBigDecimal(0);

		for (UserSalaryMonthDetail userSalaryMonthDetail : userSalaryServiceAll) {
			if (userSalaryMonthDetail.getIsExpert()) {
				expertCounts = expertCounts + 1;
			}
			myElevatorCounts = myElevatorCounts.add(userSalaryMonthDetail.getMyElevatorCounts());

			myElevatorNsCounts = myElevatorNsCounts.add(userSalaryMonthDetail.getMyElevatorNsCounts());

			myElevatorVillaCounts = myElevatorVillaCounts.add(userSalaryMonthDetail.getMyElevatorVillaCounts());

			byNullifyPlanCounts = byNullifyPlanCounts + userSalaryMonthDetail.getByNullifyPlanCounts();

			wxNullifyPlanCounts = wxNullifyPlanCounts + userSalaryMonthDetail.getWxNullifyPlanCounts();

			expertHelpCounts = expertHelpCounts + userSalaryMonthDetail.getExpertHelpCounts();

			wxExpertHelpCounts = wxExpertHelpCounts + userSalaryMonthDetail.getWxExpertHelpCounts();

			byExpertHelpCounts = byExpertHelpCounts + userSalaryMonthDetail.getByExpertHelpCounts();

			expertHelpOtherCounts = expertHelpOtherCounts + userSalaryMonthDetail.getExpertHelpOtherCounts();

			userSalary = userSalary.add(userSalaryMonthDetail.getUserSalary());

			roleSalary = roleSalary.add(userSalaryMonthDetail.getRoleSalary());

			byPerformance = byPerformance.add(userSalaryMonthDetail.getByPerformance());

			wxPerformance = wxPerformance.add(userSalaryMonthDetail.getWxPerformance());

			nsPerformance = nsPerformance.add(userSalaryMonthDetail.getNsPerformance());

			failureRatePunish = failureRatePunish.add(userSalaryMonthDetail.getFailureRatePunish());

			byNoPassPunish = byNoPassPunish.add(userSalaryMonthDetail.getByNoPassPunish());

			wxNoPassPunish = wxNoPassPunish.add(userSalaryMonthDetail.getWxNoPassPunish());

			byLiabilityPunish = byLiabilityPunish.add(userSalaryMonthDetail.getByLiabilityPunish());

			wxLiabilityPunish = wxLiabilityPunish.add(userSalaryMonthDetail.getWxLiabilityPunish());

			expertPunish = expertPunish.add(userSalaryMonthDetail.getExpertPunish());

			expertBonus = expertBonus.add(userSalaryMonthDetail.getExpertBonus());

			minSalary = minSalary.add(userSalaryMonthDetail.getMinSalary());

			performanceSalary = performanceSalary.add(userSalaryMonthDetail.getPerformanceSalary());

			disAllSalary = disAllSalary.add(userSalaryMonthDetail.getDisAllSalary());

			managerBonus = managerBonus.add(userSalaryMonthDetail.getManagerBonus());

			managerPunish = managerPunish.add(userSalaryMonthDetail.getManagerPunish());

			enAllSalary = enAllSalary.add(userSalaryMonthDetail.getEnAllSalary());
		}
		userSalarySheetVo.setExpertCounts(expertCounts);
		userSalarySheetVo.setMyElevatorNsCounts(myElevatorNsCounts);
		userSalarySheetVo.setMyElevatorVillaCounts(myElevatorVillaCounts);
		userSalarySheetVo.setMyElevatorCounts(myElevatorCounts);
		userSalarySheetVo.setByNullifyPlanCounts(byNullifyPlanCounts);
		userSalarySheetVo.setWxNullifyPlanCounts(wxNullifyPlanCounts);
		userSalarySheetVo.setExpertHelpCounts(expertHelpCounts);
		userSalarySheetVo.setWxExpertHelpCounts(wxExpertHelpCounts);
		userSalarySheetVo.setByExpertHelpCounts(byExpertHelpCounts);
		userSalarySheetVo.setExpertHelpOtherCounts(expertHelpOtherCounts);
		userSalarySheetVo.setUserSalary(userSalary);
		userSalarySheetVo.setRoleSalary(roleSalary);
		userSalarySheetVo.setByPerformance(byPerformance);
		userSalarySheetVo.setWxPerformance(wxPerformance);
		userSalarySheetVo.setNsPerformance(nsPerformance);
		userSalarySheetVo.setFailureRatePunish(failureRatePunish);
		userSalarySheetVo.setByNoPassPunish(byNoPassPunish);
		userSalarySheetVo.setWxNoPassPunish(wxNoPassPunish);
		userSalarySheetVo.setByLiabilityPunish(byLiabilityPunish);
		userSalarySheetVo.setWxLiabilityPunish(wxLiabilityPunish);
		userSalarySheetVo.setExpertPunish(expertPunish);
		userSalarySheetVo.setExpertBonus(expertBonus);
		userSalarySheetVo.setMinSalary(minSalary);
		userSalarySheetVo.setPerformanceSalary(performanceSalary);
		userSalarySheetVo.setDisAllSalary(disAllSalary);
		userSalarySheetVo.setManagerBonus(managerBonus);
		userSalarySheetVo.setManagerPunish(managerPunish);
		userSalarySheetVo.setEnAllSalary(enAllSalary);
		return userSalarySheetVo;
	}


	/**
	 * Excel 字段排序
	 *
	 * @param searchUserSalaryRules
	 * @param userSalaryMonthDetail
	 * @return
	 */
	private List<String> excelSort(List<UserSalaryRules> searchUserSalaryRules, UserSalaryMonthDetail userSalaryMonthDetail) {
		List<String> list = new ArrayList<>(32);
		for (UserSalaryRules userSalaryRules : searchUserSalaryRules) {
			if (userSalaryRules.getRulesType() == 1) {
				list.add(Convert.toStr(userSalaryMonthDetail.getUserName(), ""));
			}
			if (userSalaryRules.getRulesType() == 2) {
				list.add(Convert.toStr(userSalaryMonthDetail.getRoleNames(), ""));
			}
			if (userSalaryRules.getRulesType() == 3) {
				list.add(Convert.toStr(userSalaryMonthDetail.getGroupNames(), ""));

			}
			if (userSalaryRules.getRulesType() == 4) {
				list.add(Convert.toStr(userSalaryMonthDetail.getSkillName(), ""));

			}
			if (userSalaryRules.getRulesType() == 5) {
				list.add(Convert.toStr(userSalaryMonthDetail.getIsExpert() ? "是" : "否", ""));

			}
			if (userSalaryRules.getRulesType() == 6) {
				list.add(Convert.toStr(userSalaryMonthDetail.getMyElevatorCounts(), ""));

			}
			if (userSalaryRules.getRulesType() == 7) {
				list.add(Convert.toStr(userSalaryMonthDetail.getFaultRate().multiply(Convert.toBigDecimal(100)).setScale(2) + "%", "0"));

			}

			if (userSalaryRules.getRulesType() == 8) {
				list.add(Convert.toStr(userSalaryMonthDetail.getMyWxPlanRate().multiply(Convert.toBigDecimal(100)).setScale(2) + "%", "0"));

			}
			if (userSalaryRules.getRulesType() == 9) {
				list.add(Convert.toStr(userSalaryMonthDetail.getByNullifyPlanCounts(), ""));
			}
			if (userSalaryRules.getRulesType() == 10) {
				list.add(Convert.toStr(userSalaryMonthDetail.getWxNullifyPlanCounts(), ""));

			}
			if (userSalaryRules.getRulesType() == 11) {
				list.add(Convert.toStr(userSalaryMonthDetail.getExpertHelpCounts(), ""));
			}
			if (userSalaryRules.getRulesType() == 12) {
				list.add(Convert.toStr(userSalaryMonthDetail.getWxExpertHelpCounts(), ""));
			}
			if (userSalaryRules.getRulesType() == 13) {
				list.add(Convert.toStr(userSalaryMonthDetail.getByExpertHelpCounts(), ""));
			}
			if (userSalaryRules.getRulesType() == 14) {
				list.add(Convert.toStr(userSalaryMonthDetail.getExpertHelpOtherCounts(), ""));
			}
			if (userSalaryRules.getRulesType() == 15) {
				list.add(Convert.toStr(userSalaryMonthDetail.getUserSalary(), ""));
			}
			if (userSalaryRules.getRulesType() == 16) {
				list.add(Convert.toStr(userSalaryMonthDetail.getRoleSalary(), ""));
			}
			if (userSalaryRules.getRulesType() == 17) {
				list.add(Convert.toStr(userSalaryMonthDetail.getByPerformance(), ""));
			}
			if (userSalaryRules.getRulesType() == 18) {
				list.add(Convert.toStr(userSalaryMonthDetail.getWxPerformance(), ""));
			}
			if (userSalaryRules.getRulesType() == 19) {
				list.add(Convert.toStr(userSalaryMonthDetail.getNsPerformance(), ""));
			}
			if (userSalaryRules.getRulesType() == 20) {
				list.add(Convert.toStr(userSalaryMonthDetail.getFailureRatePunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 21) {
				list.add(Convert.toStr(userSalaryMonthDetail.getByNoPassPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 22) {
				list.add(Convert.toStr(userSalaryMonthDetail.getWxNoPassPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 23) {
				list.add(Convert.toStr(userSalaryMonthDetail.getByLiabilityPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 24) {
				list.add(Convert.toStr(userSalaryMonthDetail.getWxLiabilityPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 25) {
				list.add(Convert.toStr(userSalaryMonthDetail.getExpertPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 26) {
				list.add(Convert.toStr(userSalaryMonthDetail.getExpertBonus(), ""));
			}
			if (userSalaryRules.getRulesType() == 27) {
				list.add(Convert.toStr(userSalaryMonthDetail.getMinSalary(), ""));
			}
			if (userSalaryRules.getRulesType() == 28) {
				list.add(Convert.toStr(userSalaryMonthDetail.getPerformanceSalary(), ""));
			}
			if (userSalaryRules.getRulesType() == 29) {
				list.add(Convert.toStr(userSalaryMonthDetail.getDisAllSalary(), ""));
			}
			if (userSalaryRules.getRulesType() == 30) {
				list.add(Convert.toStr(userSalaryMonthDetail.getManagerBonus(), ""));
			}
			if (userSalaryRules.getRulesType() == 31) {
				list.add(Convert.toStr(userSalaryMonthDetail.getManagerPunish(), ""));
			}
			if (userSalaryRules.getRulesType() == 32) {
				list.add(Convert.toStr(userSalaryMonthDetail.getEnAllSalary(), ""));
			}

			if (userSalaryRules.getRulesType() == 33) {
				list.add(Convert.toStr(userSalaryMonthDetail.getMyElevatorNsCounts(), ""));
			}

			if (userSalaryRules.getRulesType() == 34) {
				list.add(Convert.toStr(userSalaryMonthDetail.getMyElevatorVillaCounts(), ""));
			}
		}
		return list;
	}


	/**
	 * Excel 汇总排序
	 *
	 * @param searchUserSalaryRules
	 * @return
	 */
	private List<String> excelSortAll(List<UserSalaryRules> searchUserSalaryRules, UserSalarySheetVo userSalarySheetVo) {
		List<String> list = new ArrayList<>(32);
		for (UserSalaryRules userSalaryRules : searchUserSalaryRules) {
			if (userSalaryRules.getRulesType() == 1) {
				list.add(Convert.toStr(userSalarySheetVo.getUserCounts()));
			}
			if (userSalaryRules.getRulesType() == 2) {
				list.add("-");
			}
			if (userSalaryRules.getRulesType() == 3) {
				list.add("-");
			}
			if (userSalaryRules.getRulesType() == 4) {
				list.add("-");
			}
			if (userSalaryRules.getRulesType() == 5) {
				list.add(Convert.toStr(userSalarySheetVo.getExpertCounts()));
			}
			if (userSalaryRules.getRulesType() == 6) {
				list.add(Convert.toStr(userSalarySheetVo.getMyElevatorCounts()));
			}
			if (userSalaryRules.getRulesType() == 7) {
				list.add("-");
			}
			if (userSalaryRules.getRulesType() == 8) {
				list.add("-");

			}
			if (userSalaryRules.getRulesType() == 9) {
				list.add(Convert.toStr(userSalarySheetVo.getByNullifyPlanCounts()));
			}
			if (userSalaryRules.getRulesType() == 10) {
				list.add(Convert.toStr(userSalarySheetVo.getWxNullifyPlanCounts()));
			}
			if (userSalaryRules.getRulesType() == 11) {
				list.add(Convert.toStr(userSalarySheetVo.getExpertHelpCounts()));
			}
			if (userSalaryRules.getRulesType() == 12) {
				list.add(Convert.toStr(userSalarySheetVo.getWxExpertHelpCounts()));
			}
			if (userSalaryRules.getRulesType() == 13) {
				list.add(Convert.toStr(userSalarySheetVo.getByExpertHelpCounts()));
			}
			if (userSalaryRules.getRulesType() == 14) {
				list.add(Convert.toStr(userSalarySheetVo.getExpertHelpOtherCounts()));
			}
			if (userSalaryRules.getRulesType() == 15) {
				list.add(Convert.toStr(userSalarySheetVo.getUserSalary()));

			}
			if (userSalaryRules.getRulesType() == 16) {
				list.add(Convert.toStr(userSalarySheetVo.getRoleSalary()));
			}
			if (userSalaryRules.getRulesType() == 17) {
				list.add(Convert.toStr(userSalarySheetVo.getByPerformance()));

			}
			if (userSalaryRules.getRulesType() == 18) {
				list.add(Convert.toStr(userSalarySheetVo.getWxPerformance()));
			}
			if (userSalaryRules.getRulesType() == 19) {
				list.add(Convert.toStr(userSalarySheetVo.getNsPerformance()));

			}
			if (userSalaryRules.getRulesType() == 20) {
				list.add(Convert.toStr(userSalarySheetVo.getFailureRatePunish()));

			}
			if (userSalaryRules.getRulesType() == 21) {
				list.add(Convert.toStr(userSalarySheetVo.getByNoPassPunish()));

			}
			if (userSalaryRules.getRulesType() == 22) {
				list.add(Convert.toStr(userSalarySheetVo.getWxNoPassPunish()));

			}
			if (userSalaryRules.getRulesType() == 23) {
				list.add(Convert.toStr(userSalarySheetVo.getByLiabilityPunish()));

			}
			if (userSalaryRules.getRulesType() == 24) {
				list.add(Convert.toStr(userSalarySheetVo.getWxLiabilityPunish()));
			}
			if (userSalaryRules.getRulesType() == 25) {
				list.add(Convert.toStr(userSalarySheetVo.getExpertPunish()));

			}
			if (userSalaryRules.getRulesType() == 26) {
				list.add(Convert.toStr(userSalarySheetVo.getExpertBonus()));

			}
			if (userSalaryRules.getRulesType() == 27) {
				list.add(Convert.toStr(userSalarySheetVo.getMinSalary()));

			}
			if (userSalaryRules.getRulesType() == 28) {
				list.add(Convert.toStr(userSalarySheetVo.getPerformanceSalary()));
			}
			if (userSalaryRules.getRulesType() == 29) {
				list.add(Convert.toStr(userSalarySheetVo.getDisAllSalary()));

			}
			if (userSalaryRules.getRulesType() == 30) {
				list.add(Convert.toStr(userSalarySheetVo.getManagerBonus()));

			}
			if (userSalaryRules.getRulesType() == 31) {
				list.add(Convert.toStr(userSalarySheetVo.getManagerPunish()));

			}
			if (userSalaryRules.getRulesType() == 32) {
				list.add(Convert.toStr(userSalarySheetVo.getEnAllSalary()));

			}
			if (userSalaryRules.getRulesType() == 33) {
				list.add(Convert.toStr(userSalarySheetVo.getMyElevatorNsCounts()));
			}
			if (userSalaryRules.getRulesType() == 34) {
				list.add(Convert.toStr(userSalarySheetVo.getMyElevatorVillaCounts()));
			}
		}
		return list;
	}


	/**
	 * Excel 排序
	 *
	 * @param searchUserSalaryRules
	 * @return
	 */
	private List<String> getExcelTitle(List<UserSalaryRules> searchUserSalaryRules) {
		List<String> list = new ArrayList<>(32);
		for (UserSalaryRules userSalaryRules : searchUserSalaryRules) {
			if (userSalaryRules.getRulesType() == 1) {
				list.add("总人数");
			}
			if (userSalaryRules.getRulesType() == 2) {
				list.add("--");
			}
			if (userSalaryRules.getRulesType() == 3) {
				list.add("--");
			}
			if (userSalaryRules.getRulesType() == 4) {
				list.add("--");
			}
			if (userSalaryRules.getRulesType() == 5) {
				list.add("技术支持总人数");
			}
			if (userSalaryRules.getRulesType() == 6) {
				list.add("单人负责梯台总数");
			}
			if (userSalaryRules.getRulesType() == 7) {
				list.add("--");
			}
			if (userSalaryRules.getRulesType() == 8) {
				list.add("--");

			}
			if (userSalaryRules.getRulesType() == 9) {
				list.add("保养不合格总单数");
			}
			if (userSalaryRules.getRulesType() == 10) {
				list.add("维修不合格总单数");

			}
			if (userSalaryRules.getRulesType() == 11) {
				list.add("申请技术支持总数");
			}
			if (userSalaryRules.getRulesType() == 12) {
				list.add("技术支持判定-维修责任总次数");
			}
			if (userSalaryRules.getRulesType() == 13) {
				list.add("技术支持判定-保养责任总次数");
			}
			if (userSalaryRules.getRulesType() == 14) {
				list.add("支持他人总次数");
			}
			if (userSalaryRules.getRulesType() == 15) {
				list.add("基础薪资总数");
			}
			if (userSalaryRules.getRulesType() == 16) {
				list.add("岗位薪资总数");
			}
			if (userSalaryRules.getRulesType() == 17) {
				list.add("保养绩效总数");
			}
			if (userSalaryRules.getRulesType() == 18) {
				list.add("维修绩效(团队贡献)总数");
			}
			if (userSalaryRules.getRulesType() == 19) {
				list.add("年审绩效总数");
			}
			if (userSalaryRules.getRulesType() == 20) {
				list.add("故障率绩效处罚总数");
			}
			if (userSalaryRules.getRulesType() == 21) {
				list.add("保养不合格处罚总数");
			}
			if (userSalaryRules.getRulesType() == 22) {
				list.add("维修不合格处罚总数");
			}
			if (userSalaryRules.getRulesType() == 23) {
				list.add("判定保养责任处罚总数");
			}
			if (userSalaryRules.getRulesType() == 24) {
				list.add("判定维修责任处罚总数");
			}
			if (userSalaryRules.getRulesType() == 25) {
				list.add("申请技术支持处罚总数");
			}
			if (userSalaryRules.getRulesType() == 26) {
				list.add("技术支持奖励总数");
			}
			if (userSalaryRules.getRulesType() == 27) {
				list.add("保底工资总数");
			}
			if (userSalaryRules.getRulesType() == 28) {
				list.add("绩效工资总数");
			}
			if (userSalaryRules.getRulesType() == 29) {
				list.add("拟发工资总数");
			}
			if (userSalaryRules.getRulesType() == 30) {
				list.add("主管奖励总数");
			}
			if (userSalaryRules.getRulesType() == 31) {
				list.add("主管处罚总数");
			}
			if (userSalaryRules.getRulesType() == 32) {
				list.add("维保绩效总工资总数");
			}
			if (userSalaryRules.getRulesType() == 33) {
				list.add("单人负责年审梯台总数");
			}
			if (userSalaryRules.getRulesType() == 34) {
				list.add("单人负责年审别墅总数");
			}
		}
		return list;
	}
}
